Java.TM. describes both a programming language and a programming environment for generating and running platform-independent code. This platform-independent code runs on a Java.TM. virtual machine, which is an abstract computing machine that interprets the platform-independent code. The Java.TM. virtual machine is described in greater detail in Lindholm and Yellin, The Java Virtual Machine Specification, Addison-Wesley (1997), which is hereby incorporated by reference. The Java.TM. virtual machine does not specifically recognize the Java.TM. programming language or any other programming language; instead, the Java virtual machine only recognizes a particular file format, the class file format. A class file contains the Java virtual machine instructions (or byte codes) that constitute the platform-independent code.
As part of running a Java program, a developer performs a number of steps, as shown in FIG. 1. First, a developer compiles a computer program (step 102). Typically, the developer has developed a computer program containing source code in a high-level language, such as the Java programming language, and invokes the Java.TM. compiler to compile the code. The Java compiler is part of the Java.TM. software development kit available from Sun Microsystems of Mountain View, Calif,. The Java compiler outputs one or more class files containing byte codes suitable for execution on the Java virtual machine. Each class file contains one type of the Java programming language, either a class or an interface. The class file format is described in greater detail on pp. 83-137 of The Java Virtual Machine Specification. Although the class file format is a robust file format, it is unable to instruct the virtual machine to statically initialize an array efficiently, thus posing a problem, discussed in greater detail below.
After compiling the program, the developer consolidates the class files output in step 102 into a single file, known as a .mclass file, by using a preloader (step 104). The preloader also available from Sun Microsystems, Inc., concatenates the class files and performs preprocessing to facilitate the execution of the class files. After consolidating the class files, the developer loads the .mclass file into a virtual machine (step 106). In this step, the Java virtual machine stores the .mclass file in memory and interprets the byte codes contained in the .mclass file by reading the byte codes and then processing and executing them. Until interpretation of the byte codes is completed, the .mclass file is stored in memory. The byte codes recognized by the Java virtual machine are more clearly described on pp. 151-338 of The Java Virtual Machine Specification.
As stated above, the class file format cannot instruct the virtual machine to statically initialize arrays. To compensate for this problem, the Java.TM. compiler generates a special method, &lt;clinit&gt;, to perform class initialization, including initialization of static arrays. An example of the initialization of a static array follows: